function ui = pml_bdry(pml_para,i,j,nx,ny,no_of_lyr,nlyr)
ui = pml_para.ui;
dt = pml_para.dt;
rhs= pml_para.rhs;

nghost = 2;
% PML参数
npml = 25;
% npml = 200;
cmax = 3000;
nn = 3;
Rtry = 1e3; % Rtry = 1/R
ui_lyr = 0;

if (i<=npml+nghost)
    ui_lyr = npml+nghost - i + 1;
end
if ((nx-i)<npml+nghost)
    ui_lyr = npml+nghost + i - nx;
end
if (no_of_lyr == nlyr)
    if ((ny-j)<npml+nghost)
        % flag = true;
    end
end

dmax = ((nn+1)*cmax)*log(Rtry)/(2*npml);

di = dmax * (ui_lyr/npml).^nn;

ui = (ui + dt * rhs)/(1 + dt * di);

end